<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>前端基础知识整理01 | 俊劫的学习基地</title>
    <meta name="generator" content="VuePress 1.7.1">
    <link rel="icon" href="/favicon.ico">
    <meta name="description" content="俊劫的学习基地是俊劫的个人博客，用于记录学习笔记、分享音乐、书籍、旅行等个人兴趣的站点。">
    <meta name="keywords" content="俊劫,俊劫的博客,博客,个人博客,vue,vuejs,vuepress,vuepress-theme-reco">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/assets/css/0.styles.5f3e1891.css" as="style"><link rel="preload" href="/assets/js/app.070ad525.js" as="script"><link rel="preload" href="/assets/js/2.1d15da37.js" as="script"><link rel="preload" href="/assets/js/39.8cd27589.js" as="script"><link rel="preload" href="/assets/js/4.aab0e518.js" as="script"><link rel="prefetch" href="/assets/js/10.46adc9c3.js"><link rel="prefetch" href="/assets/js/11.4fa3a97f.js"><link rel="prefetch" href="/assets/js/12.d930e0cf.js"><link rel="prefetch" href="/assets/js/13.ac14e905.js"><link rel="prefetch" href="/assets/js/14.5db5f3a5.js"><link rel="prefetch" href="/assets/js/15.f912d397.js"><link rel="prefetch" href="/assets/js/16.dc881375.js"><link rel="prefetch" href="/assets/js/17.4b5e68db.js"><link rel="prefetch" href="/assets/js/18.e48da6e4.js"><link rel="prefetch" href="/assets/js/19.4a02bf41.js"><link rel="prefetch" href="/assets/js/20.8437ea4c.js"><link rel="prefetch" href="/assets/js/21.618c8e36.js"><link rel="prefetch" href="/assets/js/22.097f8d74.js"><link rel="prefetch" href="/assets/js/23.512dda35.js"><link rel="prefetch" href="/assets/js/24.2afceb8f.js"><link rel="prefetch" href="/assets/js/25.a7a02005.js"><link rel="prefetch" href="/assets/js/26.a79e1590.js"><link rel="prefetch" href="/assets/js/27.d0feb2c1.js"><link rel="prefetch" href="/assets/js/28.62b630e3.js"><link rel="prefetch" href="/assets/js/29.119f3256.js"><link rel="prefetch" href="/assets/js/3.8b40c051.js"><link rel="prefetch" href="/assets/js/30.5b11ce87.js"><link rel="prefetch" href="/assets/js/31.94ce824a.js"><link rel="prefetch" href="/assets/js/32.ed4f7508.js"><link rel="prefetch" href="/assets/js/33.c74281cf.js"><link rel="prefetch" href="/assets/js/34.ffb262b0.js"><link rel="prefetch" href="/assets/js/35.ada11000.js"><link rel="prefetch" href="/assets/js/36.edb96889.js"><link rel="prefetch" href="/assets/js/37.02fd03c3.js"><link rel="prefetch" href="/assets/js/38.4e0ec907.js"><link rel="prefetch" href="/assets/js/40.e59f0b3b.js"><link rel="prefetch" href="/assets/js/41.e3da8313.js"><link rel="prefetch" href="/assets/js/42.c847d1f4.js"><link rel="prefetch" href="/assets/js/43.13c84445.js"><link rel="prefetch" href="/assets/js/44.cbaa9acf.js"><link rel="prefetch" href="/assets/js/45.cb3a266d.js"><link rel="prefetch" href="/assets/js/46.0519c642.js"><link rel="prefetch" href="/assets/js/47.3373a57e.js"><link rel="prefetch" href="/assets/js/48.7efa5760.js"><link rel="prefetch" href="/assets/js/49.923721c8.js"><link rel="prefetch" href="/assets/js/5.07f41da3.js"><link rel="prefetch" href="/assets/js/50.839ac91d.js"><link rel="prefetch" href="/assets/js/51.f98cecb2.js"><link rel="prefetch" href="/assets/js/52.041f20b3.js"><link rel="prefetch" href="/assets/js/53.9464df60.js"><link rel="prefetch" href="/assets/js/54.a9ce67d2.js"><link rel="prefetch" href="/assets/js/55.9733d4b3.js"><link rel="prefetch" href="/assets/js/56.e67c1aa1.js"><link rel="prefetch" href="/assets/js/57.1335a8a7.js"><link rel="prefetch" href="/assets/js/58.83f617d8.js"><link rel="prefetch" href="/assets/js/59.b74c2845.js"><link rel="prefetch" href="/assets/js/6.dcf50b6e.js"><link rel="prefetch" href="/assets/js/60.6e3b00bd.js"><link rel="prefetch" href="/assets/js/61.cd335db9.js"><link rel="prefetch" href="/assets/js/62.ee277d48.js"><link rel="prefetch" href="/assets/js/63.2a34cfa5.js"><link rel="prefetch" href="/assets/js/64.a51989fe.js"><link rel="prefetch" href="/assets/js/65.3abfaea5.js"><link rel="prefetch" href="/assets/js/66.d4f35c55.js"><link rel="prefetch" href="/assets/js/67.2f070f74.js"><link rel="prefetch" href="/assets/js/68.c7da856f.js"><link rel="prefetch" href="/assets/js/69.6c15fcd4.js"><link rel="prefetch" href="/assets/js/7.10c46d97.js"><link rel="prefetch" href="/assets/js/70.68b6cf93.js"><link rel="prefetch" href="/assets/js/71.c49db210.js"><link rel="prefetch" href="/assets/js/72.7ffae8af.js"><link rel="prefetch" href="/assets/js/73.abb40ede.js"><link rel="prefetch" href="/assets/js/74.71723883.js"><link rel="prefetch" href="/assets/js/75.ab7e2e75.js"><link rel="prefetch" href="/assets/js/76.936112a6.js"><link rel="prefetch" href="/assets/js/8.ec9c3735.js"><link rel="prefetch" href="/assets/js/9.b555605d.js">
    <link rel="stylesheet" href="/assets/css/0.styles.5f3e1891.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container have-rightmenu" data-v-f848d4e8><div class="global-loading-wrapper" data-v-2c41f3eb data-v-f848d4e8 data-v-f848d4e8><div class="loader-main" data-v-2c41f3eb><img src="/assets/img/loading.a592e2e5.jpg" alt="loading" data-v-2c41f3eb></div></div> <div class="hide" data-v-f848d4e8><header class="navbar" data-v-f848d4e8><div title="目录" class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><img src="/img/logo.png" alt="俊劫的学习基地" class="logo"> <span class="site-name">俊劫的学习基地</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">选择模式</h4> <ul class="color-mode-options"><li class="dark">深色模式</li><li class="light active">浅色模式</li><li class="read">阅读模式</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <ul class="suggestions" style="display:none;"></ul></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i></i>前端
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>文档教程</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/web/docs/imooc/wiki/" class="nav-link"><i class="iconfont reco-blog"></i>慕课教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/es6/" class="nav-link"><i class="iconfont reco-blog"></i>ES6 入门教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/wangdoc/javascript/" class="nav-link"><i class="iconfont reco-blog"></i>网道-JavaScript 教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/angular/" class="nav-link"><i class="iconfont reco-blog"></i>Angular 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/react/" class="nav-link"><i class="iconfont reco-blog"></i>React 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/vue/" class="nav-link"><i class="iconfont reco-blog"></i>Vue 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/node/" class="nav-link"><i class="iconfont reco-blog"></i>Node 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/babel/" class="nav-link"><i class="iconfont reco-blog"></i>Babel 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/webpack/" class="nav-link"><i class="iconfont reco-blog"></i>Webpack 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/typescript/" class="nav-link"><i class="iconfont reco-blog"></i>TypeScript 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/runoob/" class="nav-link"><i class="iconfont reco-blog"></i>菜鸟教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/docschina/" class="nav-link"><i class="iconfont reco-blog"></i>印记中文
</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-api"></i>索引
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/" class="nav-link"><i class="iconfont reco-category"></i>分类
</a></li><li class="dropdown-item"><!----> <a href="/tags/" class="nav-link"><i class="iconfont reco-tag"></i>标签
</a></li><li class="dropdown-item"><!----> <a href="/archives/" class="nav-link"><i class="iconfont reco-date"></i>归档
</a></li></ul></div></div><div class="nav-item"><a href="/bookshop/message-board/" class="nav-link"><i class="iconfont reco-suggestion"></i>留言板
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>关于
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>联系</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://github.com/alexwjj" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="/bookshop/linkme/" class="nav-link"><i class="iconfont reco-account"></i>关于我
</a></li></ul></li><li class="dropdown-item"><h4>博客</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://github.com/alexwjj/alexwjj.github.io" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-document"></i>本站源码
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://alexwjj.github.io/old-blog" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-document"></i>老版博客
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>其他</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/bookshop/friendslink/" class="nav-link"><i class="iconfont reco-friend"></i>友情链接
</a></li></ul></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-f848d4e8></div> <aside class="sidebar" data-v-f848d4e8><div class="personal-info-wrapper" data-v-34faaed8 data-v-f848d4e8><img src="/img/logo.png" alt="author-avatar" class="personal-img" data-v-34faaed8> <div class="author" data-v-34faaed8>
    俊劫
  </div> <div class="personal-info-details" data-v-34faaed8><div data-v-34faaed8>文章：<span data-v-34faaed8>54</span></div> <div data-v-34faaed8>地点：<span data-v-34faaed8>canton</span></div></div> <div class="slogan" data-v-34faaed8>
    just do it
  </div> <!----></div> <nav class="nav-links"><div class="nav-item"><a href="/" class="nav-link"><i class="iconfont reco-home"></i>首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i></i>前端
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>文档教程</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/web/docs/imooc/wiki/" class="nav-link"><i class="iconfont reco-blog"></i>慕课教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/es6/" class="nav-link"><i class="iconfont reco-blog"></i>ES6 入门教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/wangdoc/javascript/" class="nav-link"><i class="iconfont reco-blog"></i>网道-JavaScript 教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/angular/" class="nav-link"><i class="iconfont reco-blog"></i>Angular 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/react/" class="nav-link"><i class="iconfont reco-blog"></i>React 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/vue/" class="nav-link"><i class="iconfont reco-blog"></i>Vue 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/node/" class="nav-link"><i class="iconfont reco-blog"></i>Node 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/babel/" class="nav-link"><i class="iconfont reco-blog"></i>Babel 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/webpack/" class="nav-link"><i class="iconfont reco-blog"></i>Webpack 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/typescript/" class="nav-link"><i class="iconfont reco-blog"></i>TypeScript 文档
</a></li><li class="dropdown-subitem"><a href="/web/docs/runoob/" class="nav-link"><i class="iconfont reco-blog"></i>菜鸟教程
</a></li><li class="dropdown-subitem"><a href="/web/docs/docschina/" class="nav-link"><i class="iconfont reco-blog"></i>印记中文
</a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-api"></i>索引
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/categories/" class="nav-link"><i class="iconfont reco-category"></i>分类
</a></li><li class="dropdown-item"><!----> <a href="/tags/" class="nav-link"><i class="iconfont reco-tag"></i>标签
</a></li><li class="dropdown-item"><!----> <a href="/archives/" class="nav-link"><i class="iconfont reco-date"></i>归档
</a></li></ul></div></div><div class="nav-item"><a href="/bookshop/message-board/" class="nav-link"><i class="iconfont reco-suggestion"></i>留言板
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>关于
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>联系</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://github.com/alexwjj" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>GitHub
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="/bookshop/linkme/" class="nav-link"><i class="iconfont reco-account"></i>关于我
</a></li></ul></li><li class="dropdown-item"><h4>博客</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://github.com/alexwjj/alexwjj.github.io" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-document"></i>本站源码
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://alexwjj.github.io/old-blog" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-document"></i>老版博客
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li><li class="dropdown-item"><h4>其他</h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/bookshop/friendslink/" class="nav-link"><i class="iconfont reco-friend"></i>友情链接
</a></li></ul></li></ul></div></div> <!----></nav> <ul class="sidebar-links"><li><a href="/pages/74b89136d37c/" class="sidebar-link">【面试】2020年底面经</a></li><li><a href="/pages/ac34940436a4a/" aria-current="page" class="active sidebar-link">前端基础知识整理01</a></li><li><a href="/pages/aa9d140ec6135/" class="sidebar-link">前端基础知识整理02</a></li><li><a href="/pages/3cea8c7d5577f/" class="sidebar-link">xdm 来当当前端面试官</a></li><li><a href="/pages/9de40adc21b12/" class="sidebar-link">前端基础 - 手写系列</a></li><li><a href="/pages/f15a7725f87e7/" class="sidebar-link">【分享】2021新鲜面经和资源分享</a></li><li><a href="/pages/a336385364f8/" class="sidebar-link">【面试】前端求职之路</a></li></ul> </aside> <div><main class="page"><div class="theme-vdoing-wrapper bg-style-8"><div class="articleInfo-wrap" data-v-13f19dad><div class="articleInfo" data-v-13f19dad><ul class="breadcrumbs" data-v-13f19dad><li data-v-13f19dad><a href="/" title="首页" class="fa fa-laptop-house router-link-active" data-v-13f19dad></a></li> <li data-v-13f19dad><a href="/categories/?category=%E9%9D%A2%E8%AF%95%E7%9B%B8%E5%85%B3" title="分类" data-v-13f19dad>面试相关</a></li> <!----> <!----></ul> <div class="info" data-v-13f19dad><div title="作者" class="author fa fa-user" data-v-13f19dad><a href="javascript:;" data-v-13f19dad>俊劫</a></div> <div title="创建时间" class="date fa fa-calendar-alt" data-v-13f19dad><a href="javascript:;" data-v-13f19dad>2020/05/18 00:00:00</a></div> <!----></div></div></div> <!----> <div class="content-wrapper"><div class="right-menu-wrapper"><div class="right-menu-margin"><div class="right-menu-content"></div></div></div> <h1><img src="">
            前端基础知识整理01
          </h1> <div class="theme-vdoing-content content__default"><blockquote><p>比较基础，自己要多看 😈😈😈</p></blockquote> <h2 id="html知识"><a href="#html知识" class="header-anchor">#</a> <strong>HTML知识</strong></h2> <h3 id="语义化"><a href="#语义化" class="header-anchor">#</a> <strong>语义化</strong></h3> <ul><li>HTML标签的语义化是指：通过使用包含语义的HTML标签，如h1-h6、article、session、header、footer等恰当的表示文档结构</li> <li>为什么需要语义化：
<ul><li>HTML语义化让页面的内容结构化，结构更清晰，便于浏览器、搜素引擎解析</li> <li>语义化的代码，便于团队的理解和维护</li> <li>搜素引擎的爬虫更能理解上下文和关键字的权重，有利于seo</li> <li>便即使在没有样式css情况下也是以一种文档格式显示，并且容易阅读</li></ul></li></ul> <h3 id="标准模式与兼容模式"><a href="#标准模式与兼容模式" class="header-anchor">#</a> <strong>标准模式与兼容模式</strong></h3> <ul><li>标准模式的排版 和JS运作模式都是以该浏览器支持的最高标准运行。在兼容模式中，页面以宽松的向后兼容的方式显示,模拟老式浏览器的行为以防止站点无法工作</li></ul> <h3 id="doctype作用"><a href="#doctype作用" class="header-anchor">#</a> <strong>Doctype作用</strong></h3> <ul><li><code>&lt;!DOCTYPE&gt;</code>声明位于位于<code>HTML</code>文档中的第一行，处于 <code>&lt;html&gt;</code> 标签之前。告知浏览器的解析器用什么文档标准解析这个文档。<code>DOCTYPE</code>不存在或格式不正确会导致文档以兼容模式呈现</li></ul> <h3 id="行内元素与块级元素"><a href="#行内元素与块级元素" class="header-anchor">#</a> <strong>行内元素与块级元素</strong></h3> <ul><li>行内元素有：<code>a b span img input select strong</code>（强调的语气）</li> <li>块级元素有：<code>div ul ol li dl dt dd h1 h2 h3 h4…p</code></li> <li>常见的空元素（自闭合）:<code>&lt;br&gt; &lt;hr&gt; &lt;img&gt; &lt;input&gt; &lt;link&gt; &lt;meta&gt;</code></li></ul> <h3 id="link和-import导入样式的区别"><a href="#link和-import导入样式的区别" class="header-anchor">#</a> <strong>link和@import导入样式的区别</strong></h3> <ul><li><code>link</code>属于<code>XHTML</code>标签，除了加载<code>CSS</code>外，还能用于定义<code>RSS</code>,定义<code>rel</code>连接属性等作用；而<code>@import</code>是<code>CSS</code>提供的，只能用于加载<code>CSS</code></li> <li>页面被加载的时，<code>link</code>会同时被加载，而<code>@import</code>引用的<code>CSS</code>会等到页面被加载完再加载</li> <li><code>import</code>是<code>CSS2.1</code> 提出的，只在<code>IE5</code>以上才能被识别，而<code>link</code>是<code>XHTML</code>标签，无兼容问题</li></ul> <h3 id="浏览器内核的理解"><a href="#浏览器内核的理解" class="header-anchor">#</a> <strong>浏览器内核的理解</strong></h3> <ul><li>主要分成两部分：渲染引擎(<code>layout engineer</code>或<code>Rendering Engine</code>)和<code>JS</code>引擎</li> <li>渲染引擎：负责取得网页的内容（HTML、XML、图像等等）、整理讯息（例如加入CSS等），以及计算网页的显示方式，然后会输出至显示器或打印机。浏览器的内核的不同对于网页的语法解释会有不同，所以渲染的效果也不相同。所有网页浏览器、电子邮件客户端以及其它需要编辑、显示网络内容的应用程序都需要内核</li> <li>JS引擎：解析和执行javascript来实现网页的动态效果</li> <li>最开始渲染引擎和JS引擎并没有区分的很明确，后来JS引擎越来越独立，内核就倾向于只指渲染引</li></ul> <h3 id="常见的浏览器内核有哪些"><a href="#常见的浏览器内核有哪些" class="header-anchor">#</a> <strong>常见的浏览器内核有哪些</strong></h3> <ul><li><code>Trident</code>内核：<code>IE,MaxThon,TT,The World,360,搜狗浏览器</code>等</li> <li><code>Gecko</code>内核：<code>Firefox</code></li> <li><code>Presto</code>内核：<code>Opera7</code>及以上</li> <li><code>Webkit</code>内核：<code>Safari,Chrome</code>等。   <code>Chrome</code>的<code>Blink</code>（<code>WebKit</code>的分支）</li></ul> <h3 id="html5新特性"><a href="#html5新特性" class="header-anchor">#</a> <strong>HTML5新特性</strong></h3> <ul><li>HTML5 主要是关于图像，位置，存储，多任务等功能的增加
<ul><li>绘画 canvas</li> <li>用于媒介回放的 video 和 audio 元素</li> <li>本地离线存储 localStorage 长期存储数据，浏览器关闭后数据不丢失</li> <li>sessionStorage 的数据在浏览器关闭后自动删除</li> <li>语意化更好的内容元素，比如 article、footer、header、nav、section</li> <li>表单控件，calendar、date、time、email、url、search</li> <li>新的技术webworker, websocket, Geolocation</li></ul></li> <li>如何区分HTML5： DOCTYPE声明\新增的结构元素\功能元素</li></ul> <h3 id="html离线存储的使用和原理"><a href="#html离线存储的使用和原理" class="header-anchor">#</a> <strong>HTML离线存储的使用和原理</strong></h3> <ul><li><p>在用户没有与因特网连接时，可以正常访问站点或应用，在用户与因特网连接时，更新用户机器上的缓存文件</p></li> <li><p>原理：HTML5的离线存储是基于一个新建的.appcache文件的缓存机制(不是存储技术)，通过这个文件上的解析清单离线存储资源，这些资源就会像cookie一样被存储了下来。之后当网络在处于离线状态下时，浏览器会通过被离线存储的数据进行页面展示</p></li> <li><p>如何使用：</p> <ul><li>页面头部像下面一样加入一个manifest的属性；</li> <li>在cache.manifest文件的编写离线存储的资源</li> <li>在离线状态时，操作window.applicationCache进行需求实现</li></ul></li></ul> <div class="language- line-numbers-mode"><pre class="language-text"><code>CACHE MANIFEST
    #v0.11
    CACHE:
    js/app.js
    css/style.css
    NETWORK:
    resourse/logo.png
    FALLBACK:
    / /offline.html
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h3 id="浏览器是怎么对html5的离线储存资源进行管理和加载的"><a href="#浏览器是怎么对html5的离线储存资源进行管理和加载的" class="header-anchor">#</a> <strong>浏览器是怎么对HTML5的离线储存资源进行管理和加载的</strong></h3> <ul><li><p>在线的情况下，浏览器发现html头部有manifest属性，它会请求manifest文件，如果是第一次访问app，那么浏览器就会根据manifest文件的内容下载相应的资源并且进行离线存储。如果已经访问过app并且资源已经离线存储了，那么浏览器就会使用离线的资源加载页面，然后浏览器会对比新的manifest文件与旧的manifest文件，如果文件没有发生改变，就不做任何操作，如果文件改变了，那么就会重新下载文件中的资源并进行离线存储。</p></li> <li><p>离线的情况下，浏览器就直接使用离线存储的资源。</p></li></ul> <h3 id="cookies-sessionstorage-和-localstorage-的区别"><a href="#cookies-sessionstorage-和-localstorage-的区别" class="header-anchor">#</a> <strong>cookies，sessionStorage 和 localStorage 的区别</strong></h3> <ul><li><p>cookie是网站为了标示用户身份而储存在用户本地终端（Client Side）上的数据（通常经过加密）</p></li> <li><p>cookie数据始终在同源的http请求中携带（即使不需要），记会在浏览器和服务器间来回传递</p></li> <li><p><code>sessionStorage</code>和<code>localStorage</code>不会自动把数据发给服务器，仅在本地保存</p></li> <li><p>存储大小：</p> <ul><li><code>cookie</code>数据大小不能超过4k</li> <li><code>sessionStorage</code>和<code>localStorage</code>虽然也有存储大小的限制，但比cookie大得多，可以达到5M或更大</li></ul></li> <li><p>有期时间：</p> <ul><li><code>localStorage</code> 存储持久数据，浏览器关闭后数据不丢失除非主动删除数据</li> <li><code>sessionStorage</code>  数据在当前浏览器窗口关闭后自动删除</li> <li><code>cookie</code>  设置的<code>cookie</code>过期时间之前一直有效，即使窗口或浏览器关闭</li></ul></li></ul> <h3 id="iframe有那些缺点"><a href="#iframe有那些缺点" class="header-anchor">#</a> <strong>iframe有那些缺点</strong></h3> <ul><li>iframe会阻塞主页面的Onload事件</li> <li>搜索引擎的检索程序无法解读这种页面，不利于SEO</li> <li>iframe和主页面共享连接池，而浏览器对相同域的连接有限制，所以会影响页面的并行加载</li> <li>使用<code>iframe</code>之前需要考虑这两个缺点。如果需要使用<code>iframe</code>，最好是通过<code>javascript</code>动态给<code>iframe</code>添加<code>src</code>属性值，这样可以绕开以上两个问题</li></ul> <h3 id="label标签的作用和使用网页"><a href="#label标签的作用和使用网页" class="header-anchor">#</a> <strong>label标签的作用和使用网页</strong></h3> <ul><li>label标签来定义表单控制间的关系,当用户选择该标签时，浏览器会自动将焦点转到和标签相关的表单控件</li></ul> <h3 id="html5的form如何关闭自动完成功能"><a href="#html5的form如何关闭自动完成功能" class="header-anchor">#</a> <strong>HTML5的form如何关闭自动完成功能？</strong></h3> <ul><li>给不想要提示的 form 或某个 input 设置为 autocomplete=off。</li></ul> <h3 id="网页验证码的作用"><a href="#网页验证码的作用" class="header-anchor">#</a> <strong>网页验证码的作用</strong></h3> <ul><li>区分用户是计算机还是人的公共全自动程序，可以防止恶意破解密码、刷票、论坛灌水</li> <li>有效防止黑客对某一个特定注册用户用特定程序暴力破解方式进行不断的登陆尝试</li></ul> <h2 id="css知识"><a href="#css知识" class="header-anchor">#</a> CSS知识</h2> <h3 id="display-none-与-visibility-hidden-的区别"><a href="#display-none-与-visibility-hidden-的区别" class="header-anchor">#</a> <strong>display: none; 与 visibility: hidden; 的区别</strong></h3> <ul><li>联系：它们都能让元素不可见</li> <li>区别：
<ul><li><code>display:none</code>;会让元素完全从渲染树中消失，渲染的时候不占据任何空间；<code>visibility: hidden</code>;不会让元素从渲染树消失，渲染师元素继续占据空间，只是内容不可见</li> <li><code>display: none</code>;是非继承属性，子孙节点消失由于元素从渲染树消失造成，通过修改子孙节点属性无法显示；<code>visibility:hidden</code>;是继承属性，子孙节点消失由于继承了<code>hidden</code>，通过设置<code>visibility: visible</code>;可以让子孙节点显式</li> <li>修改常规流中元素的<code>display</code>通常会造成文档重排。修改<code>visibility</code>属性只会造成本元素的重绘</li> <li>读屏器不会读取<code>display: none;</code>元素内容；会读取<code>visibility: hidden</code>元素内容</li></ul></li></ul> <h3 id="css有哪些继承属性"><a href="#css有哪些继承属性" class="header-anchor">#</a> <strong>CSS有哪些继承属性</strong></h3> <ul><li>关于文字排版的属性如：
<ul><li><code>font</code> <ul><li><code>word-break</code></li> <li><code>letter-spacing</code></li> <li><code>text-align</code></li> <li><code>text-rendering</code></li> <li><code>word-spacing</code></li> <li><code>white-space</code></li> <li><code>text-indent</code></li> <li><code>text-transform</code></li> <li><code>text-shadow</code></li></ul></li> <li><code>line-height</code></li> <li><code>color</code></li> <li><code>visibility</code></li> <li><code>cursor</code></li></ul></li> <li>不可继承的属性：<code>border padding margin width height</code></li></ul> <h3 id="外边距重叠"><a href="#外边距重叠" class="header-anchor">#</a> <strong>外边距重叠</strong></h3> <ul><li>相邻的两个盒子（可能是兄弟关系也可能是祖先关系）的外边距可以结合成一个单独的外边距。
这种合并外边距的方式被称为折叠，结合而成的外边距称为折叠外边距</li> <li>折叠结果遵循下列计算规则：
<ul><li>两个相邻的外边距都是正数时，折叠结果是它们两者之间较大的值</li> <li>两个相邻的外边距都是负数时，折叠结果是两者绝对值的较大值</li> <li>两个外边距一正一负时，折叠结果是两者的相加的和</li></ul></li></ul> <h3 id="标准盒模型和怪异盒模型"><a href="#标准盒模型和怪异盒模型" class="header-anchor">#</a> <strong>标准盒模型和怪异盒模型</strong></h3> <ul><li>盒模型： 内容(content)、填充(padding)、边界(margin)、 边框(border)；</li> <li>怪异盒模型（IE）的content部分把 border 和 padding计算了进去</li></ul> <h3 id="css优先级"><a href="#css优先级" class="header-anchor">#</a> <strong>CSS优先级</strong></h3> <ul><li>相同权重，定义最近者为准：行内样式 &gt; 内部样式 &gt; 外部样式</li> <li>含外部载入样式时，后载入样式覆盖其前面的载入的样式和内部样式</li> <li>选择器优先级: 行内样式[1000] &gt; id[100] &gt; class[10] &gt; Tag[1]</li> <li>在同一组属性设置中，!important 优先级最高，高于行内样式</li></ul> <h3 id="css3新增伪类"><a href="#css3新增伪类" class="header-anchor">#</a> <strong>CSS3新增伪类</strong></h3> <div class="language- line-numbers-mode"><pre class="language-text"><code>p:first-of-type 选择属于其父元素的首个 &lt;p&gt; 元素的每个 &lt;p&gt; 元素。
p:last-of-type  选择属于其父元素的最后 &lt;p&gt; 元素的每个 &lt;p&gt; 元素。
p:only-of-type  选择属于其父元素唯一的 &lt;p&gt; 元素的每个 &lt;p&gt; 元素。
p:only-child        选择属于其父元素的唯一子元素的每个 &lt;p&gt; 元素。
p:nth-child(2)  选择属于其父元素的第二个子元素的每个 &lt;p&gt; 元素。

:after          在元素之前添加内容,也可以用来做清除浮动。
:before         在元素之后添加内容
:enabled        
:disabled       控制表单控件的禁用状态。
:checked        单选框或复选框被选中
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br></div></div><h3 id="如何居中div"><a href="#如何居中div" class="header-anchor">#</a> <strong>如何居中div</strong></h3> <ul><li>给<code>div</code>设置一个宽度，然后添加<code>margin:0 auto</code>属性</li></ul> <div class="language- line-numbers-mode"><pre class="language-text"><code>div{
    width:200px;
    margin:0 auto;
 }
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><ul><li>浮动元素居中</li></ul> <div class="language- line-numbers-mode"><pre class="language-text"><code>//确定容器的宽高 宽500 高 300 的层
//设置层的外边距
 .div {
      width:500px ; 
      height:300px;
      margin: -150px 0 0 -250px;
      position:relative;         //相对定位
      left:50%;
      top:50%;
 }
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><ul><li>绝对定位的div居中</li></ul> <div class="language- line-numbers-mode"><pre class="language-text"><code> position: absolute;
 width: 1200px;
 left: 50%;
 top: 50%;
 transform: translate3d(-50%,-50%,0);
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><h3 id="display"><a href="#display" class="header-anchor">#</a> <strong>display</strong></h3> <ul><li>block         像块类型元素一样显示。</li> <li>none          元素消失，不在文档流中</li> <li>inline-block  像行内元素一样显示。</li> <li>list-item     象块类型元素一样显示，并添加样式列表标记。</li> <li>table         此元素会作为块级表格来显示</li> <li>inherit       规定应该从父元素继承 display 属性的值</li> <li>flex          flex布局</li> <li>table-cell    类似表格的自适应布局</li></ul> <h3 id="position的值relative和absolute定位原点"><a href="#position的值relative和absolute定位原点" class="header-anchor">#</a> <strong>position的值relative和absolute定位原点</strong></h3> <ul><li>absolute
<ul><li>生成绝对定位的元素，相对于值不为 static的第一个父元素进行定位。</li></ul></li> <li>fixed （老IE不支持）
<ul><li>生成绝对定位的元素，相对于浏览器窗口进行定位。</li></ul></li> <li>relative
<ul><li>生成相对定位的元素，相对于其正常位置进行定位。</li></ul></li> <li>static
<ul><li>默认值。没有定位，元素出现在正常的流中（忽略 top, bottom, left, right - z-index 声明）。</li></ul></li> <li>inherit
<ul><li>规定从父元素继承 position 属性的值</li></ul></li></ul> <h3 id="css3的新特性"><a href="#css3的新特性" class="header-anchor">#</a> <strong>CSS3的新特性</strong></h3> <ul><li>新增选择器     p:nth-child(n){color: rgba(255, 0, 0, 0.75)}</li> <li>弹性盒模型     display: flex;</li> <li>多列布局       column-count: 5;</li> <li>媒体查询       @media (max-width: 480px) {.box: {column-count: 1;}}</li> <li>个性化字体     @font-face{font-family: BorderWeb; src:url(BORDERW0.eot);}</li> <li>颜色透明度     color: rgba(255, 0, 0, 0.75);</li> <li>圆角           border-radius: 5px;</li> <li>渐变           background:linear-gradient(red, green, blue);</li> <li>阴影           box-shadow:3px 3px 3px rgba(0, 64, 128, 0.3);</li> <li>倒影           box-reflect: below 2px;</li> <li>文字装饰       text-stroke-color: red;</li> <li>文字溢出       text-overflow:ellipsis;</li> <li>背景效果       background-size: 100px 100px;</li> <li>边框效果       border-image:url(bt_blue.png) 0 10;</li> <li>转换
<ul><li>旋转          transform: rotate(20deg);</li> <li>倾斜          transform: skew(150deg, -10deg);</li> <li>位移          transform: translate(20px, 20px);</li> <li>缩放          transform: scale(.5);</li></ul></li> <li>平滑过渡       transition: all .3s ease-in .1s;</li> <li>动画           @keyframes anim-1 {50% {border-radius: 50%;}} animation: anim-1 1s;</li></ul> <h3 id="用纯css创建一个三角形"><a href="#用纯css创建一个三角形" class="header-anchor">#</a> <strong>用纯CSS创建一个三角形</strong></h3> <div class="language- line-numbers-mode"><pre class="language-text"><code>// 把上、左、右三条边隐藏掉（颜色设为 transparent）
#demo {
 width: 0;
 height: 0;
 border-width: 20px;
 border-style: solid;
 border-color: transparent transparent red transparent;
}
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><h3 id="一个满屏-品-字布局-如何设计"><a href="#一个满屏-品-字布局-如何设计" class="header-anchor">#</a> <strong>一个满屏 品 字布局 如何设计</strong></h3> <ul><li>简单的方式：
<ul><li>上面的div宽100%，</li> <li>下面的两个div分别宽50%，</li> <li>然后用float或者inline使其不换行即可</li></ul></li></ul> <h3 id="为什么要初始化css样式"><a href="#为什么要初始化css样式" class="header-anchor">#</a> <strong>为什么要初始化CSS样式</strong></h3> <ul><li>因为浏览器的兼容问题，不同浏览器对有些标签的默认值是不同的，如果没对CSS初始化往往会出现浏览器之间的页面显示差异</li></ul> <h3 id="display-inline-block产生间隙"><a href="#display-inline-block产生间隙" class="header-anchor">#</a> <strong>display:inline-block产生间隙</strong></h3> <ul><li>原因：换行或空格会占据一定的位置</li> <li>解决方法：
<ul><li>除去当前元素的空格或换行</li> <li>当前元素的父元素中设置font-size:0;</li> <li>在当前元素的父元素中设置letter-spaceing:-4px;</li></ul></li></ul> <h3 id="隐藏元素的方法"><a href="#隐藏元素的方法" class="header-anchor">#</a> <strong>隐藏元素的方法</strong></h3> <ul><li>visibility: hidden;   这个属性只是简单的隐藏某个元素，但是元素占用的空间任然存在</li> <li>opacity: 0;           CSS3属性，设置0可以使一个元素完全透明</li> <li>position: absolute;   设置一个很大的 left 负值定位，使元素定位在可见区域之外</li> <li>display: none;        元素会变得不可见，并且不会再占用文档的空间。</li> <li>transform: scale(0);  将一个元素设置为缩放无限小，元素将不可见，元素原来所在的位置将被保留</li> <li><code>&lt;div hidden=&quot;hidden&quot;&gt;</code> HTML5属性,效果和display:none;相同，但这个属性用于记录一个元素的状态</li> <li>height: 0;            将元素高度设为 0 ，并消除边框</li> <li>filter: blur(0);      CSS3属性，将一个元素的模糊度设置为0，从而使这个元素“消失”在页面中</li></ul> <h3 id="rgba-和-opacity-的透明效果有什么不同"><a href="#rgba-和-opacity-的透明效果有什么不同" class="header-anchor">#</a> <strong>rgba() 和 opacity 的透明效果有什么不同</strong></h3> <ul><li>opacity 作用于元素以及元素内的所有内容（包括文字）的透明度</li> <li>rgba() 只作用于元素自身的颜色或其背景色，子元素不会继承透明效果</li></ul> <h3 id="css-属性-content-的作用"><a href="#css-属性-content-的作用" class="header-anchor">#</a> <strong>css 属性 content 的作用</strong></h3> <ul><li>content 属性专门应用在 before/after 伪元素上，用于插入额外内容或样式</li></ul> <h3 id="li与li之间有看不见的空白间隔"><a href="#li与li之间有看不见的空白间隔" class="header-anchor">#</a> <strong>li与li之间有看不见的空白间隔</strong></h3> <ul><li>li排列受到中间空白(回车/空格)等的影响，因为空白也属于字符，会被应用样式占据空间，产生间隔</li> <li>解决办法：在ul设置设置font-size=0,在li上设置需要的文字大小</li></ul> <h3 id="圣杯布局"><a href="#圣杯布局" class="header-anchor">#</a> <strong>圣杯布局</strong></h3> <ul><li>要求：三列布局；中间主体内容前置，且宽度自适应；两边内容定宽
<ul><li>好处：重要的内容放在文档流前面可以优先渲染</li> <li>原理：利用相对定位、浮动、负边距布局，而不添加额外标签</li></ul></li></ul> <div class="language-css line-numbers-mode"><pre class="language-css"><code>  <span class="token selector">.container</span> <span class="token punctuation">{</span>
      <span class="token property">padding-left</span><span class="token punctuation">:</span> 150px<span class="token punctuation">;</span>
      <span class="token property">padding-right</span><span class="token punctuation">:</span> 190px<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
  <span class="token selector">.main</span> <span class="token punctuation">{</span>
      <span class="token property">float</span><span class="token punctuation">:</span> left<span class="token punctuation">;</span>
      <span class="token property">width</span><span class="token punctuation">:</span> 100%<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
  <span class="token selector">.left</span> <span class="token punctuation">{</span>
      <span class="token property">float</span><span class="token punctuation">:</span> left<span class="token punctuation">;</span>
      <span class="token property">width</span><span class="token punctuation">:</span> 190px<span class="token punctuation">;</span>
      <span class="token property">margin-left</span><span class="token punctuation">:</span> -100%<span class="token punctuation">;</span>
      <span class="token property">position</span><span class="token punctuation">:</span> relative<span class="token punctuation">;</span>
      <span class="token property">left</span><span class="token punctuation">:</span> -150px<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
  <span class="token selector">.right</span> <span class="token punctuation">{</span>
      <span class="token property">float</span><span class="token punctuation">:</span> left<span class="token punctuation">;</span>
      <span class="token property">width</span><span class="token punctuation">:</span> 190px<span class="token punctuation">;</span>
      <span class="token property">margin-left</span><span class="token punctuation">:</span> -190px<span class="token punctuation">;</span>
      <span class="token property">position</span><span class="token punctuation">:</span> relative<span class="token punctuation">;</span>
      <span class="token property">right</span><span class="token punctuation">:</span> -190px<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br></div></div><h3 id="双飞翼布局"><a href="#双飞翼布局" class="header-anchor">#</a> <strong>双飞翼布局</strong></h3> <ul><li>双飞翼布局：对圣杯布局（使用相对定位，对以后布局有局限性）的改进，消除相对定位布局</li> <li>原理：主体元素上设置左右边距，预留两翼位置。左右两栏使用浮动和负边距归位，消除相对定位。</li></ul> <div class="language-css line-numbers-mode"><pre class="language-css"><code><span class="token selector">.container</span> <span class="token punctuation">{</span>
    <span class="token comment">/*padding-left:150px;*/</span>
    <span class="token comment">/*padding-right:190px;*/</span>
<span class="token punctuation">}</span>
<span class="token selector">.main-wrap</span> <span class="token punctuation">{</span>
    <span class="token property">width</span><span class="token punctuation">:</span> 100%<span class="token punctuation">;</span>
    <span class="token property">float</span><span class="token punctuation">:</span> left<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector">.main</span> <span class="token punctuation">{</span>
    <span class="token property">margin-left</span><span class="token punctuation">:</span> 150px<span class="token punctuation">;</span>
    <span class="token property">margin-right</span><span class="token punctuation">:</span> 190px<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token selector">.left</span> <span class="token punctuation">{</span>
    <span class="token property">float</span><span class="token punctuation">:</span> left<span class="token punctuation">;</span>
    <span class="token property">width</span><span class="token punctuation">:</span> 150px<span class="token punctuation">;</span>
    <span class="token property">margin-left</span><span class="token punctuation">:</span> -100%<span class="token punctuation">;</span>
    <span class="token comment">/*position: relative;*/</span>
    <span class="token comment">/*left:-150px;*/</span>
<span class="token punctuation">}</span>
<span class="token selector">.right</span> <span class="token punctuation">{</span>
    <span class="token property">float</span><span class="token punctuation">:</span> left<span class="token punctuation">;</span>
    <span class="token property">width</span><span class="token punctuation">:</span> 190px<span class="token punctuation">;</span>
    <span class="token property">margin-left</span><span class="token punctuation">:</span> -190px<span class="token punctuation">;</span>
    <span class="token comment">/*position:relative;*/</span>
    <span class="token comment">/*right:-190px;*/</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br></div></div><h3 id="在css样式中常使用-px、em-在表现上有什么区别"><a href="#在css样式中常使用-px、em-在表现上有什么区别" class="header-anchor">#</a> <strong>在CSS样式中常使用 px、em 在表现上有什么区别</strong></h3> <ul><li>px 相对于显示器屏幕分辨率，无法用浏览器字体放大功能</li> <li>em 值并不是固定的，会继承父级的字体大小： em = 像素值 / 父级font-size</li></ul> <h3 id="浮动元素"><a href="#浮动元素" class="header-anchor">#</a> <strong>浮动元素</strong></h3> <ul><li>工作原理：
<ul><li>浮动元素脱离文档流，不占据空间（引起“高度塌陷”现象）</li> <li>浮动元素碰到包含它的边框或者其他浮动元素的边框停留</li></ul></li> <li>引起的问题：
<ul><li>父元素的高度无法被撑开，影响与父元素同级的元素</li> <li>与浮动元素同级的非浮动元素会跟随其后</li></ul></li> <li>清除浮动的方式
<ul><li>添加额外标签，例如 <code>&lt;div style=&quot;clear:both&quot;&gt;&lt;/div&gt;</code></li> <li>使用 br 标签和其自身的 clear 属性，例如 <code>&lt;br clear=&quot;all&quot; /&gt;</code></li> <li>父元素设置 overflow：hidden; 在IE6中还需要触发 hasLayout，例如zoom：1;</li> <li>父元素也设置浮动</li> <li>使用 :after 伪元素</li></ul></li></ul> <div class="language- line-numbers-mode"><pre class="language-text"><code>.clearfix:after{
   content: &quot;\200B&quot;;
   display: table; 
   height: 0;
   clear: both;
 }
 .clearfix{
   *zoom: 1;
 }
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h3 id="css-预处理器"><a href="#css-预处理器" class="header-anchor">#</a> <strong>CSS 预处理器</strong></h3> <ul><li>CSS 预处理器基本思想：为 CSS 增加了一些编程的特性（变量、逻辑判断、函数等）</li> <li>开发者使用这种语言进行进行 Web 页面样式设计，再编译成正常的 CSS 文件使用</li> <li>使用 CSS 预处理器，可以使 CSS 更加简洁、适应性更强、可读性更佳，无需考虑兼容性</li> <li>最常用的 CSS 预处理器语言包括：Sass（SCSS）和 LESS</li></ul> <h3 id="css优化、提高性能的方法"><a href="#css优化、提高性能的方法" class="header-anchor">#</a> <strong>CSS优化、提高性能的方法</strong></h3> <ul><li>多个css合并，尽量减少HTTP请求</li> <li>将css文件放在页面最上面</li> <li>移除空的css规则</li> <li>避免使用CSS表达式</li> <li>选择器优化嵌套，尽量避免层级过深</li> <li>充分利用css继承属性，减少代码量</li> <li>抽象提取公共样式，减少代码量</li> <li>属性值为0时，不加单位</li> <li>属性值为小于1的小数时，省略小数点前面的0</li> <li>css雪碧图</li></ul> <h3 id="浏览器是怎样解析css选择器的"><a href="#浏览器是怎样解析css选择器的" class="header-anchor">#</a> <strong>浏览器是怎样解析CSS选择器的</strong></h3> <ul><li>浏览器解析 CSS 选择器的方式是从右到左</li></ul> <h3 id="抽离样式模块"><a href="#抽离样式模块" class="header-anchor">#</a> <strong>抽离样式模块</strong></h3> <ul><li>CSS可以拆分成2部分：公共CSS 和 业务CSS：
<ul><li>网站的配色，字体，交互提取出为公共CSS。这部分CSS命名不应涉及具体的业务</li> <li>对于业务CSS，需要有统一的命名，使用公用的前缀。可以参考面向对象的CSS</li></ul></li></ul> <h3 id="响应式设计"><a href="#响应式设计" class="header-anchor">#</a> <strong>响应式设计</strong></h3> <ul><li>响应式设计就是网站能够兼容多个终端，而不是为每个终端做一个特定的版本</li> <li>基本原理是利用CSS3媒体查询，为不同尺寸的设备适配不同样式</li> <li>对于低版本的IE，可采用JS获取屏幕宽度，然后通过resize方法来实现兼容</li></ul> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code><span class="token function">$</span><span class="token punctuation">(</span>window<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">resize</span><span class="token punctuation">(</span><span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token function">screenRespond</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token function">screenRespond</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">function</span> <span class="token function">screenRespond</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
<span class="token keyword">var</span> screenWidth <span class="token operator">=</span> <span class="token function">$</span><span class="token punctuation">(</span>window<span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">width</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>screenWidth <span class="token operator">&lt;=</span> <span class="token number">1800</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token function">$</span><span class="token punctuation">(</span><span class="token string">&quot;body&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">attr</span><span class="token punctuation">(</span><span class="token string">&quot;class&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;w1800&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>screenWidth <span class="token operator">&lt;=</span> <span class="token number">1400</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token function">$</span><span class="token punctuation">(</span><span class="token string">&quot;body&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">attr</span><span class="token punctuation">(</span><span class="token string">&quot;class&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;w1400&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token keyword">if</span><span class="token punctuation">(</span>screenWidth <span class="token operator">&gt;</span> <span class="token number">1800</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
  <span class="token function">$</span><span class="token punctuation">(</span><span class="token string">&quot;body&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">attr</span><span class="token punctuation">(</span><span class="token string">&quot;class&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br></div></div><h3 id="伪元素和伪类"><a href="#伪元素和伪类" class="header-anchor">#</a> <strong>伪元素和伪类</strong></h3> <ul><li>伪元素
<ul><li>在内容元素的前后插入额外的元素或样式，但是这些元素实际上并不在文档中生成。</li> <li>伪元素用 :: 表示,由于低版本IE对双冒号不兼容，开发者为了兼容性各浏览器，继续使使用 :after 这种老语法表示伪元素</li></ul></li> <li>伪类
<ul><li>将特殊的效果添加到特定选择器上。它是已有元素上添加类别的，不会产生新的元素</li> <li>在 CSS 中伪类一直用 : 表示</li></ul></li></ul> <div class="language- line-numbers-mode"><pre class="language-text"><code>a:hover {color: #FF00FF}
p:first-child {color: red}
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><h3 id="如何修改chrome记住密码后自动填充表单的黄色背景"><a href="#如何修改chrome记住密码后自动填充表单的黄色背景" class="header-anchor">#</a> <strong>如何修改Chrome记住密码后自动填充表单的黄色背景</strong></h3> <ul><li>产生原因：由于Chrome默认会给自动填充的input表单加上 input:-webkit-autofill 私有属性造成的</li> <li>解决方案1：在form标签上直接关闭了表单的自动填充：autocomplete=&quot;off&quot;</li> <li>解决方案2：input:-webkit-autofill { background-color: transparent; }</li></ul> <h3 id="line-height的理解"><a href="#line-height的理解" class="header-anchor">#</a> <strong>line-height的理解</strong></h3> <ul><li>line-height 指一行字的高度，包含了字间距，实际上是下一行基线到上一行基线距离</li> <li>一个容器没有设置高度，那么撑开容器高度的是 line-height 而不是容器内的文字内容</li> <li>把 line-height 值设置为 height 一样大小的值可以实现单行文字的垂直居中</li> <li>赋值方式
<ul><li>带单位：px 是固定值，而 em 会参考父元素 font-size 值计算自身的行高</li> <li>纯数字：会把比例传递给后代。例如，父级行高为 1.5，子元素字体为 18px，则子元素行高为 1.5 * 18 = 27px</li> <li>百分比：将计算后的值传递给后代</li></ul></li></ul> <h3 id="怎么让chrome支持小于12px-的文字"><a href="#怎么让chrome支持小于12px-的文字" class="header-anchor">#</a> <strong>怎么让Chrome支持小于12px 的文字</strong></h3> <div class="language-css line-numbers-mode"><pre class="language-css"><code>  <span class="token selector">.shrink</span><span class="token punctuation">{</span>
    <span class="token property">-webkit-transform</span><span class="token punctuation">:</span><span class="token function">scale</span><span class="token punctuation">(</span>0.8<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token property">-o-transform</span><span class="token punctuation">:</span><span class="token function">scale</span><span class="token punctuation">(</span>1<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token property">display</span><span class="token punctuation">:</span>inline-block<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><h3 id="让页面里的字体变清晰-变细用css怎么做"><a href="#让页面里的字体变清晰-变细用css怎么做" class="header-anchor">#</a> <strong>让页面里的字体变清晰，变细用CSS怎么做</strong></h3> <div class="language-css line-numbers-mode"><pre class="language-css"><code>  <span class="token property">-webkit-font-smoothing</span><span class="token punctuation">:</span> antialiased<span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><h3 id="动画的最小时间间隔是多久"><a href="#动画的最小时间间隔是多久" class="header-anchor">#</a> <strong>动画的最小时间间隔是多久</strong></h3> <ul><li>16.7ms 多数显示器默认频率是60Hz，即1秒刷新60次，所以理论上最小间隔: 1s / 60 * 1000 ＝ 16.7ms</li></ul> <h2 id="js知识"><a href="#js知识" class="header-anchor">#</a> JS知识</h2> <h3 id="javascript的组成"><a href="#javascript的组成" class="header-anchor">#</a> <strong>JavaScript的组成</strong></h3> <ul><li>JavaScript 由以下三部分组成：
<ul><li>ECMAScript（核心）：JavaScript 语言基础</li> <li>DOM（文档对象模型）：规定了访问HTML和XML的接口</li> <li>BOM（浏览器对象模型）：提供了浏览器窗口之间进行交互的对象和方法</li></ul></li></ul> <h3 id="js的基本数据类型和引用数据类型"><a href="#js的基本数据类型和引用数据类型" class="header-anchor">#</a> <strong>JS的基本数据类型和引用数据类型</strong></h3> <ul><li>基本数据类型：undefined、null、boolean、number、string、symbol</li> <li>引用数据类型：object、array、function</li></ul> <h3 id="如何编写高性能的javascript"><a href="#如何编写高性能的javascript" class="header-anchor">#</a> <strong>如何编写高性能的JavaScript</strong></h3> <ul><li>遵循严格模式：&quot;use strict&quot;;</li> <li>将js脚本放在页面底部，加快渲染页面</li> <li>将js脚本将脚本成组打包，减少请求</li> <li>使用非阻塞方式下载js脚本</li> <li>尽量使用局部变量来保存全局变量</li> <li>尽量减少使用闭包</li> <li>使用 window 对象属性方法时，省略 window</li> <li>尽量减少对象成员嵌套</li> <li>缓存 DOM 节点的访问</li> <li>通过避免使用 eval() 和 Function() 构造器</li> <li>给 setTimeout() 和 setInterval() 传递函数而不是字符串作为参数</li> <li>尽量使用直接量创建对象和数组</li> <li>最小化重绘(repaint)和回流(reflow)</li></ul> <h3 id="描述浏览器的渲染过程-dom树和渲染树的区别"><a href="#描述浏览器的渲染过程-dom树和渲染树的区别" class="header-anchor">#</a> <strong>描述浏览器的渲染过程，DOM树和渲染树的区别</strong></h3> <ul><li><p>浏览器的渲染过程：</p> <ul><li>解析HTML构建 DOM(DOM树)，并行请求 css/image/js</li> <li>CSS 文件下载完成，开始构建 CSSOM(CSS树)</li> <li>CSSOM 构建结束后，和 DOM 一起生成 Render Tree(渲染树)</li> <li>布局(Layout)：计算出每个节点在屏幕中的位置</li> <li>显示(Painting)：通过显卡把页面画到屏幕上</li></ul></li> <li><p>DOM树 和 渲染树 的区别：</p> <ul><li>DOM树与HTML标签一一对应，包括head和隐藏元素</li> <li>渲染树不包括head和隐藏元素，大段文本的每一个行都是独立节点，每一个节点都有对应的css属性</li></ul></li></ul> <h3 id="重绘和回流-重排-的区别和关系"><a href="#重绘和回流-重排-的区别和关系" class="header-anchor">#</a> <strong>重绘和回流（重排）的区别和关系</strong></h3> <ul><li>重绘：当渲染树中的元素外观（如：颜色）发生改变，不影响布局时，产生重绘</li> <li>回流：当渲染树中的元素的布局（如：尺寸、位置、隐藏/状态状态）发生改变时，产生重绘回流</li> <li>注意：JS获取Layout属性值（如：offsetLeft、scrollTop、getComputedStyle等）也会引起回流。因为浏览器需要通过回流计算最新值</li> <li>回流必将引起重绘，而重绘不一定会引起回流</li></ul> <h3 id="如何最小化重绘-repaint-和回流-reflow"><a href="#如何最小化重绘-repaint-和回流-reflow" class="header-anchor">#</a> <strong>如何最小化重绘(repaint)和回流(reflow)</strong></h3> <ul><li>需要要对元素进行复杂的操作时，可以先隐藏(display:&quot;none&quot;)，操作完成后再显示</li> <li>需要创建多个DOM节点时，使用DocumentFragment创建完后一次性的加入document</li> <li>缓存Layout属性值，如：var left = elem.offsetLeft; 这样，多次使用 left 只产生一次回流</li> <li>尽量避免用table布局（table元素一旦触发回流就会导致table里所有的其它元素回流）</li> <li>避免使用css表达式(expression)，因为每次调用都会重新计算值（包括加载页面）</li> <li>尽量使用 css 属性简写，如：用 border 代替 border-width, border-style, border-color</li> <li>批量修改元素样式：elem.className 和 elem.style.cssText 代替 elem.style.xxx</li></ul> <h3 id="解释javascript中的作用域与变量声明提升"><a href="#解释javascript中的作用域与变量声明提升" class="header-anchor">#</a> <strong>解释JavaScript中的作用域与变量声明提升</strong></h3> <ul><li><p>JavaScript作用域：</p> <ul><li>在Java、C等语言中，作用域为for语句、if语句或{}内的一块区域，称为作用域；</li> <li>而在 JavaScript 中，作用域为function(){}内的区域，称为函数作用域。</li></ul></li> <li><p>JavaScript变量声明提升：</p> <ul><li>在JavaScript中，函数声明与变量声明经常被JavaScript引擎隐式地提升到当前作用域的顶部。</li> <li>声明语句中的赋值部分并不会被提升，只有名称被提升</li> <li>函数声明的优先级高于变量，如果变量名跟函数名相同且未赋值，则函数声明会覆盖变量声明</li> <li>如果函数有多个同名参数，那么最后一个参数（即使没有定义）会覆盖前面的同名参数</li></ul></li></ul> <h3 id="介绍javascript的原型-原型链-有什么特点"><a href="#介绍javascript的原型-原型链-有什么特点" class="header-anchor">#</a> <strong>介绍JavaScript的原型，原型链，有什么特点</strong></h3> <ul><li><p>原型：</p> <ul><li>JavaScript的所有对象中都包含了一个 [<strong>proto</strong>] 内部属性，这个属性所对应的就是该对象的原型</li> <li>JavaScript的函数对象，除了原型 [<strong>proto</strong>] 之外，还预置了 prototype 属性</li> <li>当函数对象作为构造函数创建实例时，该 prototype 属性值将被作为实例对象的原型 [<strong>proto</strong>]。</li></ul></li> <li><p>原型链：</p> <ul><li>当一个对象调用的属性/方法自身不存在时，就会去自己 [<strong>proto</strong>] 关联的前辈 prototype 对象上去找</li> <li>如果没找到，就会去该 prototype 原型 [<strong>proto</strong>] 关联的前辈 prototype 去找。依次类推，直到找到属性/方法或 undefined 为止。从而形成了所谓的“原型链”</li></ul></li> <li><p>原型特点：</p> <ul><li>JavaScript对象是通过引用来传递的，当修改原型时，与之相关的对象也会继承这一改变</li></ul></li></ul> <h3 id="javascript如何实现继承"><a href="#javascript如何实现继承" class="header-anchor">#</a> <strong>Javascript如何实现继承</strong></h3> <ul><li>构造函数绑定：使用 call 或 apply 方法，将父对象的构造函数绑定在子对象上</li></ul> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code><span class="token keyword">function</span> <span class="token function">Cat</span><span class="token punctuation">(</span><span class="token parameter">name<span class="token punctuation">,</span>color</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
 　<span class="token function">Animal</span><span class="token punctuation">.</span><span class="token function">apply</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">,</span> arguments<span class="token punctuation">)</span><span class="token punctuation">;</span>
 　<span class="token keyword">this</span><span class="token punctuation">.</span>name <span class="token operator">=</span> name<span class="token punctuation">;</span>
 　<span class="token keyword">this</span><span class="token punctuation">.</span>color <span class="token operator">=</span> color<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br></div></div><ul><li>实例继承：将子对象的 prototype 指向父对象的一个实例</li></ul> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code><span class="token class-name">Cat</span><span class="token punctuation">.</span>prototype <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Animal</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token class-name">Cat</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>constructor <span class="token operator">=</span> Cat<span class="token punctuation">;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><ul><li>拷贝继承：如果把父对象的所有属性和方法，拷贝进子对象</li></ul> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code>    <span class="token keyword">function</span> <span class="token function">extend</span><span class="token punctuation">(</span><span class="token parameter">Child<span class="token punctuation">,</span> Parent</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  　　　<span class="token keyword">var</span> p <span class="token operator">=</span> <span class="token class-name">Parent</span><span class="token punctuation">.</span>prototype<span class="token punctuation">;</span>
  　　　<span class="token keyword">var</span> c <span class="token operator">=</span> <span class="token class-name">Child</span><span class="token punctuation">.</span>prototype<span class="token punctuation">;</span>
  　　　<span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">var</span> i <span class="token keyword">in</span> p<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  　　　   c<span class="token punctuation">[</span>i<span class="token punctuation">]</span> <span class="token operator">=</span> p<span class="token punctuation">[</span>i<span class="token punctuation">]</span><span class="token punctuation">;</span>
  　　　<span class="token punctuation">}</span>
  　　　c<span class="token punctuation">.</span>uber <span class="token operator">=</span> p<span class="token punctuation">;</span>
  　 <span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><ul><li>原型继承：将子对象的 prototype 指向父对象的 prototype</li></ul> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code>    <span class="token keyword">function</span> <span class="token function">extend</span><span class="token punctuation">(</span><span class="token parameter">Child<span class="token punctuation">,</span> Parent</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">var</span> <span class="token function-variable function">F</span> <span class="token operator">=</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">;</span>
      　<span class="token constant">F</span><span class="token punctuation">.</span>prototype <span class="token operator">=</span> <span class="token class-name">Parent</span><span class="token punctuation">.</span>prototype<span class="token punctuation">;</span>
      　Child<span class="token punctuation">.</span>prototype <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">F</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      　Child<span class="token punctuation">.</span>prototype<span class="token punctuation">.</span>constructor <span class="token operator">=</span> Child<span class="token punctuation">;</span>
      　Child<span class="token punctuation">.</span>uber <span class="token operator">=</span> <span class="token class-name">Parent</span><span class="token punctuation">.</span>prototype<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><ul><li>ES6 语法糖 extends：class ColorPoint extends Point {}</li></ul> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code>    <span class="token keyword">class</span> <span class="token class-name">ColorPoint</span> <span class="token keyword">extends</span> <span class="token class-name">Point</span> <span class="token punctuation">{</span>
       <span class="token function">constructor</span><span class="token punctuation">(</span><span class="token parameter">x<span class="token punctuation">,</span> y<span class="token punctuation">,</span> color</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
          <span class="token keyword">super</span><span class="token punctuation">(</span>x<span class="token punctuation">,</span> y<span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 调用父类的constructor(x, y)</span>
          <span class="token keyword">this</span><span class="token punctuation">.</span>color <span class="token operator">=</span> color<span class="token punctuation">;</span>
       <span class="token punctuation">}</span>
       <span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
          <span class="token keyword">return</span> <span class="token keyword">this</span><span class="token punctuation">.</span>color <span class="token operator">+</span> <span class="token string">' '</span> <span class="token operator">+</span> <span class="token keyword">super</span><span class="token punctuation">.</span><span class="token function">toString</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 调用父类的toString()</span>
       <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br></div></div><h3 id="javascript作用链域"><a href="#javascript作用链域" class="header-anchor">#</a> <strong>Javascript作用链域</strong></h3> <ul><li>全局函数无法查看局部函数的内部细节，但局部函数可以查看其上层的函数细节，直至全局细节</li> <li>如果当前作用域没有找到属性或方法，会向上层作用域查找，直至全局函数，这种形式就是作用域链</li></ul> <h3 id="谈谈this对象的理解"><a href="#谈谈this对象的理解" class="header-anchor">#</a> <strong>谈谈this对象的理解</strong></h3> <ul><li>this 总是指向函数的直接调用者</li> <li>如果有 new 关键字，this 指向 new 出来的实例对象</li> <li>在事件中，this指向触发这个事件的对象</li> <li>IE下 attachEvent 中的this总是指向全局对象Window</li></ul> <h3 id="什么是-window-对象-什么是-document-对象"><a href="#什么是-window-对象-什么是-document-对象" class="header-anchor">#</a> <strong>什么是 Window 对象，什么是 Document 对象</strong></h3> <ul><li>Window 对象表示当前浏览器的窗口，是JavaScript的顶级对象。</li> <li>我们创建的所有对象、函数、变量都是 Window 对象的成员。</li> <li>Window 对象的方法和属性是在全局范围内有效的。</li> <li>Document 对象是 HTML 文档的根节点与所有其他节点（元素节点，文本节点，属性节点, 注释节点）</li> <li>Document 对象使我们可以通过脚本对 HTML 页面中的所有元素进行访问</li> <li>Document 对象是 Window 对象的一部分，可通过 window.document 属性对其进行访问</li></ul> <h3 id="事件的三个阶段"><a href="#事件的三个阶段" class="header-anchor">#</a> <strong>事件的三个阶段</strong></h3> <ul><li>捕获、目标、冒泡</li></ul> <h3 id="在一个dom上同时绑定两个点击事件-一个用捕获-一个用冒泡。事件会执行几次-先执行冒泡还是捕获"><a href="#在一个dom上同时绑定两个点击事件-一个用捕获-一个用冒泡。事件会执行几次-先执行冒泡还是捕获" class="header-anchor">#</a> <strong>在一个DOM上同时绑定两个点击事件：一个用捕获，一个用冒泡。事件会执行几次，先执行冒泡还是捕获</strong></h3> <ul><li>该DOM上的事件如果被触发，会执行两次（执行次数等于绑定次数）</li> <li>如果该DOM是目标元素，则按事件绑定顺序执行，不区分冒泡/捕获</li> <li>如果该DOM是处于事件流中的非目标元素，则先执行捕获，后执行冒泡</li></ul> <h3 id="什么是函数节流-介绍一下应用场景和原理"><a href="#什么是函数节流-介绍一下应用场景和原理" class="header-anchor">#</a> <strong>什么是函数节流，介绍一下应用场景和原理</strong></h3> <ul><li><p>函数节流(throttle)是指阻止一个函数在很短时间间隔内连续调用。
只有当上一次函数执行后达到规定的时间间隔，才能进行下一次调用。
但要保证一个累计最小调用间隔（否则拖拽类的节流都将无连续效果）</p></li> <li><p>函数节流用于 onresize, onscroll 等短时间内会多次触发的事件</p></li> <li><p>函数节流的原理：使用定时器做时间节流。
当触发一个事件时，先用 setTimout 让这个事件延迟一小段时间再执行。
如果在这个时间间隔内又触发了事件，就 clearTimeout 原来的定时器，
再 setTimeout 一个新的定时器重复以上流程。</p></li> <li><p>函数节流简单实现：</p></li></ul> <div class="language-javascript line-numbers-mode"><pre class="language-javascript"><code><span class="token keyword">function</span> <span class="token function">throttle</span><span class="token punctuation">(</span><span class="token parameter">method<span class="token punctuation">,</span> context</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
     <span class="token function">clearTimeout</span><span class="token punctuation">(</span>methor<span class="token punctuation">.</span>tId<span class="token punctuation">)</span><span class="token punctuation">;</span>
     method<span class="token punctuation">.</span>tId <span class="token operator">=</span> <span class="token function">setTimeout</span><span class="token punctuation">(</span><span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
         <span class="token function">method</span><span class="token punctuation">.</span><span class="token function">call</span><span class="token punctuation">(</span>context<span class="token punctuation">)</span><span class="token punctuation">;</span>
     <span class="token punctuation">}</span>， <span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token comment">// 两次调用至少间隔 100ms</span>
<span class="token punctuation">}</span>
<span class="token comment">// 调用</span>
window<span class="token punctuation">.</span><span class="token function-variable function">onresize</span> <span class="token operator">=</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
    <span class="token function">throttle</span><span class="token punctuation">(</span>myFunc<span class="token punctuation">,</span> window<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br></div></div><h3 id="null-undefined-的区别"><a href="#null-undefined-的区别" class="header-anchor">#</a> <strong>null，undefined 的区别</strong></h3> <ul><li><p>undefined   表示不存在这个值。</p></li> <li><p>undefined :是一个表示&quot;无&quot;的原始值或者说表示&quot;缺少值&quot;，就是此处应该有一个值，但是还没有定义。当尝试读取时会返回 undefined</p></li> <li><p>例如变量被声明了，但没有赋值时，就等于undefined</p></li> <li><p>null 表示一个对象被定义了，值为“空值”</p></li> <li><p>null : 是一个对象(空对象, 没有任何属性和方法)</p></li> <li><p>例如作为函数的参数，表示该函数的参数不是对象；</p></li> <li><p>在验证null时，一定要使用　=== ，因为 == 无法分别 null 和　undefined</p></li></ul> <h3 id="dom操作-怎样添加、移除、移动、复制、创建和查找节点"><a href="#dom操作-怎样添加、移除、移动、复制、创建和查找节点" class="header-anchor">#</a> <strong>DOM操作——怎样添加、移除、移动、复制、创建和查找节点</strong></h3> <ul><li>（1）创建新节点
<ul><li>createDocumentFragment() //创建一个DOM片段</li> <li>createElement()   //创建一个具体的元素</li> <li>createTextNode()   //创建一个文本节点</li></ul></li> <li>（2）添加、移除、替换、插入
<ul><li>appendChild()</li> <li>removeChild()</li> <li>replaceChild()</li> <li>insertBefore() //在已有的子节点前插入一个新的子节点</li></ul></li> <li>（3）查找
<ul><li>getElementsByTagName()    //通过标签名称</li> <li>getElementsByName()    // 通过元素的Name属性的值(IE容错能力较强，会得到一个数组，其中包括id等于name值的)</li> <li>getElementById()    //通过元素Id，唯一性</li></ul></li></ul> <h3 id="渐进增强和优雅降级"><a href="#渐进增强和优雅降级" class="header-anchor">#</a> <strong>渐进增强和优雅降级</strong></h3> <ul><li><p>渐进增强 ：针对低版本浏览器进行构建页面，保证最基本的功能，然后再针对高级浏览器进行效果、交互等改进和追加功能达到更好的用户体验。</p></li> <li><p>优雅降级 ：一开始就构建完整的功能，然后再针对低版本浏览器进行兼容</p></li></ul> <h3 id="javascript-的同源策略和作用"><a href="#javascript-的同源策略和作用" class="header-anchor">#</a> <strong>JavaScript 的同源策略和作用</strong></h3> <ul><li>同源策略指的是：协议，域名，端口相同，同源策略是一种安全协议</li> <li>作用：比如一个黑客程序，他利用Iframe把真正的银行登录页面嵌到他的页面上，当你使用真实的用户名，密码登录时，他的页面就可以通过Javascript读取到你的表单中input中的内容，这样用户名，密码就轻松到手了。</li></ul></div></div> <div class="page-edit"><div class="tags"><a href="/tags/?tag=%E9%9D%A2%E8%AF%95" title="标签">#面试</a></div> <div class="last-updated"><span class="prefix">最近更新时间：</span> <span class="time">2021/05/01 17:06:28</span></div></div> <div class="page-nav-wapper"><div class="page-nav-centre-wrap"><a href="/pages/74b89136d37c/" class="page-nav-centre page-nav-centre-prev"><div class="tooltip">【面试】2020年底面经</div></a> <a href="/pages/aa9d140ec6135/" class="page-nav-centre page-nav-centre-next"><div class="tooltip">前端基础知识整理02</div></a></div> <div class="page-nav"><p class="inner"><span class="prev">
        ←
        <a href="/pages/74b89136d37c/" class="prev">【面试】2020年底面经</a></span> <span class="next"><a href="/pages/aa9d140ec6135/">前端基础知识整理02</a>→
      </span></p></div></div></div> <div class="theme-vdoing-wrapper article-list bg-style-7"><div class="article-title"><a href="/archives/" class="fa fa-pencil-alt">
      最近更新
    </a></div> <div class="article-wrapper"><dl><dd>01</dd> <dt><div><a href="/pages/512f6ae339a31/"><div>【TypesScript主题月】5.7</div></a></div> <div class="date"><span>2021/05/06 00:00:00</span></div></dt></dl><dl><dd>02</dd> <dt><div><a href="/pages/136f8f068dffe/"><div>【React主题月】4月完结</div></a></div> <div class="date"><span>2021/04/30 00:00:00</span></div></dt></dl><dl><dd>03</dd> <dt><div><a href="/pages/55e7bb3eb7802/"><div>【算法打卡】先来一个波集合</div></a></div> <div class="date"><span>2021/04/22 00:00:00</span></div></dt></dl> <div class="more-box"><a href="/archives/" class="more"><i class="fas fa-angle-double-right"></i>前往更多 ...
      </a></div></div></div> <div class="comments-wrapper" style="display:none;"><!----></div></main></div> <div class="footer-wrapper" data-v-51417878 data-v-51417878><span class="footer-reco-theme" data-v-51417878><i class="iconfont reco-github" data-v-51417878></i> <a target="blank" href="https://github.com/alexwjj/alexwjj.github.io" data-v-51417878>alexwjj.github.io@5.0</a></span> <!----> <span class="footer-copyright" data-v-51417878><i class="iconfont reco-copyright" data-v-51417878></i> <a data-v-51417878><span data-v-51417878>俊劫</span> <span class="ml5" data-v-51417878>
          2018 - 2021
        </span></a></span> <span class="footer-view-site" data-v-51417878><i class="iconfont reco-eye" data-v-51417878></i> <span id="busuanzi_container_site_uv" data-v-51417878>
        访客数：<span id="busuanzi_value_site_uv" class="num" data-v-51417878>-</span></span> <span id="busuanzi_container_site_pv" class="ml5" data-v-51417878>
        访问量：<span id="busuanzi_value_site_pv" class="num" data-v-51417878>-</span></span></span> <!----></div> <!----></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-c6073ba8 data-v-c6073ba8><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-c6073ba8><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-c6073ba8></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-c6073ba8></path></svg></div><!----><div></div></div></div>
    <script src="/assets/js/app.070ad525.js" defer></script><script src="/assets/js/2.1d15da37.js" defer></script><script src="/assets/js/39.8cd27589.js" defer></script><script src="/assets/js/4.aab0e518.js" defer></script>
  </body>
</html>
